import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

/**
 * @author: Administrator
 * @date: 2022-10-13 21:23
 * @desc:
 */

public class test {

    @Test
    public void test1() throws IOException, ClassNotFoundException, SQLException {
        InputStream is = ClassLoader.getSystemClassLoader().getResourceAsStream("application.properties");
        Properties pros = new Properties();
        pros.load(is);
        String driver = pros.getProperty("spring.datasource.driver-class-name");
        String url = pros.getProperty("spring.datasource.url");
        String username = pros.getProperty("spring.datasource.username");
        String password = pros.getProperty("spring.datasource.password");

        Class.forName(driver);

        Connection connection = DriverManager.getConnection(url, username, password);
        System.out.println(connection);
    }
}
